package com.candy.dao.impl;

import com.candy.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDaoImpl implements AccountDao {

    private JdbcTemplate jdbcTemplate;
//入账
    @Override
    public void addMoney(String innerUser, Double innerMoney) {
        String strSql="UPDATE account SET money=money+"+innerMoney+" WHERE `name`='"+innerUser+"'";
        jdbcTemplate.update(strSql);
    }

    @Override
    public void subMoney(String outterUser, Double outtererMoney) {
        String strSql="UPDATE account SET money=money-"+outtererMoney+" WHERE `name`='"+outterUser+"'";
        jdbcTemplate.update(strSql);

    }

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
}
